<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center odlpass_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub odlpass_fd0_0'>
					<view class='flex flex-wrap align-center odlpass_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  odlpass_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='odlpass_fd0_0_c1_c0'>修改密码</text>
					</view>
					<view class='flex flex-wrap align-center justify-end odlpass_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout odlpass_flex_1">
				<view class='flex flex-direction flex-wrap align-stretch flex-sub odlpass_fd1_0'>
					<view class='flex flex-wrap align-center justify-between flex-sub odlpass_fd1_0_c0'>
						<text class='odlpass_fd1_0_c0_c0'>旧密码：</text>
						<benben-input class='odlpass_fd1_0_c0_c1' type="text" :placeholder="`请输入旧密码`"
							confirm-type="done" :maxlength="-1" :adjust-position='true'
							placeholder-style="color:rgba(162, 162, 162, 1);font-size:28rpx" v-model="oldPass" />
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub odlpass_fd1_0_c0'>
						<text class='odlpass_fd1_0_c0_c0'>新密码：</text>
						<benben-input class='odlpass_fd1_0_c0_c1' type="text" :placeholder="`请输入新密码`"
							confirm-type="done" :maxlength="-1" :adjust-position='true'
							placeholder-style="color:rgba(162, 162, 162, 1);font-size:28rpx" v-model="newPass" />
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub odlpass_fd1_0_c2'>
						<text class='odlpass_fd1_0_c0_c0'>确认新密码：</text>
						<benben-input class='odlpass_fd1_0_c0_c1' type="text" :placeholder="`请再次输入新密码`"
							confirm-type="done" :maxlength="-1" :adjust-position='true'
							placeholder-style="color:rgba(162, 162, 162, 1);font-size:28rpx" v-model="Pass" />
					</view>
				</view>
			</view>

			<!---flex布局flex布局结束-->
			<view class="flex flex-direction flex-wrap align-center benben-position-layout flex odlpass_flex_2"
				:style="{height:(150+bottomSafeAreaRpx)+'rpx',paddingBottom:bottomSafeAreaRpx+'rpx', }">
				<button class='odlpass_fd2_0' @tap.stop="calcanFunc()">完成</button>

			</view>
			<view :style="{height: (150+bottomSafeAreaRpx)+'rpx'}"></view>


		</view>
	</page-body>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	import CryptoJS from 'crypto-js';
function md5Encrypt(message) {
		return CryptoJS.MD5(message).toString();
	}
	export default {
		components: {},


		data() {
			return {
				"oldPass": "",
				"newPass": "",
				"Pass": ""
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//提交
			async calcanFunc() {
				
				if (!validate(this.oldPass, 'require')) {
					this.$message.info('请输入旧密码');
					return false;
				}
				if (!validate(this.newPass, 'require')) {
					this.$message.info('请输入新密码');
					return false;
				}
				if (!validate(this.Pass, 'require')) {
					this.$message.info('请输入确认密码');
					return false;
				}
				if(this.newPass != this.Pass){
					this.$message.info('新密码不一致')
					return
				}
				let url=global.apiUrls.post5da9ab4c4c7af
				let group=uni.getStorageSync('USER_GROUP')
				let encryptedMessage = md5Encrypt(this.newPass); // 要加密的信息
				if(group==2){
					url='/v1/5da9ab4c4c7af'
				}
				console.log(global.apiUrls.post5da9ab4c4c7af)
				let data5da9ab4c4c7af = await this.$api.post(url, {
					old_password: this.oldPass,
					password: group==2?encryptedMessage:this.newPass,
					password_code: group==2?encryptedMessage:this.Pass
				});

				if (data5da9ab4c4c7af.data.code != 1) {
					this.$message.info(data5da9ab4c4c7af.data.msg);
					return
				}
				let info5da9ab4c4c7af = data5da9ab4c4c7af.data;
				this.$message.info('修改成功')
				setTimeout(() => {
					this.$store.commit('logout')
					this.toLoginDiy();
				}, 800)
				
				
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F6f6f6;
		background-size: 100% auto;
	}

	.odlpass_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.odlpass_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 700;
		color: #333333;
		line-height: 50rpx;
	}

	.odlpass_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.odlpass_fd0_0_c0 {
		width: 120rpx;
	}

	.odlpass_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.odlpass_flex_1 {
		padding: 24rpx;
	}

	.odlpass_fd1_0_c2 {
		width: 100%;
		height: 200rpx;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.odlpass_fd1_0_c0_c1 {
		text-align: right;
	}

	.odlpass_fd1_0_c0_c0 {
		font-size: 32rpx;
		line-height: 45rpx;
		color: rgba(51, 51, 51, 1);
	}

	.odlpass_fd1_0_c0 {
		border-bottom: 1px solid rgba(238, 238, 238, 1);
		width: 100%;
		height: 200rpx;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.odlpass_fd1_0 {
		background: #Fff;
		border-radius: 16rpx;
		background-size: 100% auto;
		padding: 0rpx 024rpx 0rpx 024rpx;
	}

	.odlpass_flex_2 {
		width: 750rpx;
		height: 150rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.odlpass_fd2_0 {
		background: #145efd;
		border-radius: 45rpx;
		width: 638rpx;
		line-height: 88rpx;
		font-size: 32rpx;
		color: #fff;
		height: 88rpx;
	}
</style>